package com.blac

import android.app.Activity
import android.content.Context
import com.blac.bridge.CocosBridge
import java.lang.ref.WeakReference

object Business {
    lateinit var mContext :WeakReference<Context>
    const val GAME_MAIN_CLS = "org.cocos2dx.javascript.AppActivity"
    val LIB_PATH="org.cocos2dx.lib";
    val COCOS2DX_ACTIVITY_PATH = "$LIB_PATH.Cocos2dxActivity"
    val COCOS2DX_JJB_PATH ="$LIB_PATH.Cocos2dxJavascriptJavaBridge"

    fun init(context: Context){
        try {
            mContext=WeakReference(context)
        }catch (e:Exception){
            e.printStackTrace()
        }
    }

    fun onActivityCreate(activity: Activity){
        try {
            if (activity.javaClass.name == GAME_MAIN_CLS){
                CocosBridge.setMainGameActivity(activity)
            }
        }catch (e:Exception){
            e.printStackTrace()
        }
    }
}